Suppress #Include errors

Did anybody figure out how to suppress #Include statement errors in Attr-DXL? I know the -logfile switch can suppress interpret and run-time errors, but it doesn't suppress no-such-file #include errors.

I want to open a module with #include attr-DXL to servers that no longer exist.

-Louie
llandale - Wed Aug 22 09:51:37 EDT 2012

Re: Suppress #Include errors
Mathias Mamsch - Thu Aug 23 03:52:54 EDT 2012

Well, I create a new formal module 'm'. Put a DXL attribute with the dxl: #include <lkjlkj> in there. (temporarily create the file), save, close. Delete the file. Opening the module from the database explorer I get an error. Now I open it by DXL:
 

noError(); Module m = read ("m", false); lastError(); 
print (null m); close m

 


I get no error. Are noError/lastError not working for you? Regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: Suppress #Include errors
llandale - Thu Aug 23 10:17:33 EDT 2012

Mathias Mamsch - Thu Aug 23 03:52:54 EDT 2012

Well, I create a new formal module 'm'. Put a DXL attribute with the dxl: #include <lkjlkj> in there. (temporarily create the file), save, close. Delete the file. Opening the module from the database explorer I get an error. Now I open it by DXL:
 

noError(); Module m = read ("m", false); lastError(); 
print (null m); close m

 


I get no error. Are noError/lastError not working for you? Regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

My objective was to suppress the errors when the user double clicks to open. I came up with this:

string PreOpen = 
"    bool preOpen(Trigger trg)
        {  ModuleVersion mv = version(trg)   // Module we intend to open
           if (null mv)   infoBox(\"preOpen, null mv\")
           else 
           {  infoBox(\"preOpen '\" name(mv) \"'\")
              noError()
              share(fullName(mv), true, false, false) // this does NOT re-trigger the trigger
              lastError()
           }
           return(false)   // module opens above, this prevents the originalo "open" from firing.
        }
 
        Trigger t = current
        if (preOpen(t)) //
        then set(trigPreConPass)
        else set(trigPreConFail)
"   // end 'string PreOpen'
 
if     (confirm("Delete??")) then {delete ("PreOpen",  project->module->all, pre,  open, 10)}
elseif(confirm("Deploy??")) then {trigger("PreOpen",  project->module->all, pre,  open, 10, PreOpen)}


but I don't know how the trigger can know which mode the user is requesting; in this case I presume "share".

Re: Suppress #Include errors
Mathias Mamsch - Thu Aug 23 16:54:40 EDT 2012

llandale - Thu Aug 23 10:17:33 EDT 2012

My objective was to suppress the errors when the user double clicks to open. I came up with this:

string PreOpen = 
"    bool preOpen(Trigger trg)
        {  ModuleVersion mv = version(trg)   // Module we intend to open
           if (null mv)   infoBox(\"preOpen, null mv\")
           else 
           {  infoBox(\"preOpen '\" name(mv) \"'\")
              noError()
              share(fullName(mv), true, false, false) // this does NOT re-trigger the trigger
              lastError()
           }
           return(false)   // module opens above, this prevents the originalo "open" from firing.
        }
 
        Trigger t = current
        if (preOpen(t)) //
        then set(trigPreConPass)
        else set(trigPreConFail)
"   // end 'string PreOpen'
 
if     (confirm("Delete??")) then {delete ("PreOpen",  project->module->all, pre,  open, 10)}
elseif(confirm("Deploy??")) then {trigger("PreOpen",  project->module->all, pre,  open, 10, PreOpen)}


but I don't know how the trigger can know which mode the user is requesting; in this case I presume "share".

I remember that I experimented with a similar thing. A Pre-Open trigger that will 'noError' and a post-open trigger that will do lastError, but that had some strange effects, since some stuff goes on between pre-open and post open where one wanted errors to occur (but I do not remember what exactly). Another bad thing was, that the trigger would apply also to all DXL scripts, getting in their way of opening the module exactly how they wanted it.

I guess when it comes to double clicking and opening from the explorer, the best thing you could do is modifying the client code. When it is really only the double click, then you can do something tricky:
 

evalTop_ "void dummy(DBE x,int y) { noError(); doubleClickCB(x,y); lastError(); }; set (dbExpList , selectCB, selectCB, dummy)"

 


Rehook the double click callback of the Database Explorer and wrap it with noError/lastError ... You can do the same for the menus, but for this you need to modify "baseWindowMenu.inc". You need wrappers for the three functions, openShare, openReadOnly, openEdit:

 

 

 

...
void openReadOnlyNoError() {
  noError(); 
  openReadOnly()
  lastError(); 
}
 
void openShareNoError() {
  noError(); 
  openShare()
  lastError(); 
}
 
void openEditNoError () {
   noError(); 
   openEdit()
   lastError();
}
 
void addOpenMenuItems() {
 
    createItem(canOpenFolder, openFolder ,LS_("String_Open",NLSTEMP_("Open")), 'O', 'O',modKeyCtrl, null, null, LS_("String_Open_the_selected_folder",
               NLSTEMP_("Open the selected folder.")), LS_("String_You_must_select_a_folder_to_open",NLSTEMP_("You must select a folder to open.")))
 
    createMenu(canOpenModuleAny, LS_("String_Open",NLSTEMP_("Open")), 'O', null);
 
    createItem(canOpenModuleReadOnly ,openReadOnlyNoError ,LS_("String_Read_only",NLSTEMP_("Read-only")),'R', 'R', modKeyCtrl, null, null, 
               LS_("String_Open_the_selected_module_read_only",NLSTEMP_("Open the selected module read-only.")),
               LS_("String_You_have_no_access_to_open_the_selected_module_read_only",NLSTEMP_("You have no access to open the selected module read-only.")))
 
    createItem(canOpenModuleShare, openShareNoError, LS_("String_Shareable_Edit",NLSTEMP_("Shareable Edit")),'S', 'S', modKeyCtrl, null, null,
               LS_("String_Open_the_selected_module_for_shareable_edit",NLSTEMP_("Open the selected module for shareable edit.")),
               LS_("String_You_have_no_access_to_open_the_selected_module_for_shareable_edit",
               NLSTEMP_("You have no access to open the selected module for shareable edit.")));
 
    createItem(canOpenModuleFull, openEditNoError, LS_("String_Exclusive_Edit",NLSTEMP_("Exclusive Edit")),'E', 'E', modKeyCtrl, null, null, 
               LS_("String_Open_the_selected_module_for_exclusive_edit",NLSTEMP_("Open the selected module for exclusive edit.")),
               LS_("String_You_have_no_access_to_open_the_selected_module_for_exclusive_edit",
               NLSTEMP_("You have no access to open the selected module for exclusive edit.")));
 
    end menu // Open
 
}



and while you are at it you can place the new double click callback also in the startup files. Unfortunately the callbacks are set in baseWindowShow4.inc which is the LAST include that is to be called by doors.exe, so we cannot just place the code in some unencrypted include file. Therefore you need to rename baseWindowShow4.inc to baseWindowShow4_.inc and place a new baseWindowShow4.inc in the lib/dxl/config folder:



 

 

 

#include <config/baseWindowShow4_.inc>
 
// lets introduce the new hook for db explorer list 
void doubleClickCBNoError (DBE x,int y) { noError(); doubleClickCB(x,y); lastError(); }
set (dbExpList , selectCB, selectCB, doubleClickCBNoError )



Voila. Over are the times, where people need to press away those annoying error boxes. I am not sure if there is a trigger solution, that works without any bad side effects. If you find one, I would be all ears... Regards, Mathias



 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Suppress #Include errors
llandale - Fri Aug 24 09:14:30 EDT 2012

Mathias Mamsch - Thu Aug 23 16:54:40 EDT 2012

I remember that I experimented with a similar thing. A Pre-Open trigger that will 'noError' and a post-open trigger that will do lastError, but that had some strange effects, since some stuff goes on between pre-open and post open where one wanted errors to occur (but I do not remember what exactly). Another bad thing was, that the trigger would apply also to all DXL scripts, getting in their way of opening the module exactly how they wanted it.

I guess when it comes to double clicking and opening from the explorer, the best thing you could do is modifying the client code. When it is really only the double click, then you can do something tricky:
 

evalTop_ "void dummy(DBE x,int y) { noError(); doubleClickCB(x,y); lastError(); }; set (dbExpList , selectCB, selectCB, dummy)"

 


Rehook the double click callback of the Database Explorer and wrap it with noError/lastError ... You can do the same for the menus, but for this you need to modify "baseWindowMenu.inc". You need wrappers for the three functions, openShare, openReadOnly, openEdit:

 

 

 

...
void openReadOnlyNoError() {
  noError(); 
  openReadOnly()
  lastError(); 
}
 
void openShareNoError() {
  noError(); 
  openShare()
  lastError(); 
}
 
void openEditNoError () {
   noError(); 
   openEdit()
   lastError();
}
 
void addOpenMenuItems() {
 
    createItem(canOpenFolder, openFolder ,LS_("String_Open",NLSTEMP_("Open")), 'O', 'O',modKeyCtrl, null, null, LS_("String_Open_the_selected_folder",
               NLSTEMP_("Open the selected folder.")), LS_("String_You_must_select_a_folder_to_open",NLSTEMP_("You must select a folder to open.")))
 
    createMenu(canOpenModuleAny, LS_("String_Open",NLSTEMP_("Open")), 'O', null);
 
    createItem(canOpenModuleReadOnly ,openReadOnlyNoError ,LS_("String_Read_only",NLSTEMP_("Read-only")),'R', 'R', modKeyCtrl, null, null, 
               LS_("String_Open_the_selected_module_read_only",NLSTEMP_("Open the selected module read-only.")),
               LS_("String_You_have_no_access_to_open_the_selected_module_read_only",NLSTEMP_("You have no access to open the selected module read-only.")))
 
    createItem(canOpenModuleShare, openShareNoError, LS_("String_Shareable_Edit",NLSTEMP_("Shareable Edit")),'S', 'S', modKeyCtrl, null, null,
               LS_("String_Open_the_selected_module_for_shareable_edit",NLSTEMP_("Open the selected module for shareable edit.")),
               LS_("String_You_have_no_access_to_open_the_selected_module_for_shareable_edit",
               NLSTEMP_("You have no access to open the selected module for shareable edit.")));
 
    createItem(canOpenModuleFull, openEditNoError, LS_("String_Exclusive_Edit",NLSTEMP_("Exclusive Edit")),'E', 'E', modKeyCtrl, null, null, 
               LS_("String_Open_the_selected_module_for_exclusive_edit",NLSTEMP_("Open the selected module for exclusive edit.")),
               LS_("String_You_have_no_access_to_open_the_selected_module_for_exclusive_edit",
               NLSTEMP_("You have no access to open the selected module for exclusive edit.")));
 
    end menu // Open
 
}



and while you are at it you can place the new double click callback also in the startup files. Unfortunately the callbacks are set in baseWindowShow4.inc which is the LAST include that is to be called by doors.exe, so we cannot just place the code in some unencrypted include file. Therefore you need to rename baseWindowShow4.inc to baseWindowShow4_.inc and place a new baseWindowShow4.inc in the lib/dxl/config folder:



 

 

 

#include <config/baseWindowShow4_.inc>
 
// lets introduce the new hook for db explorer list 
void doubleClickCBNoError (DBE x,int y) { noError(); doubleClickCB(x,y); lastError(); }
set (dbExpList , selectCB, selectCB, doubleClickCBNoError )



Voila. Over are the times, where people need to press away those annoying error boxes. I am not sure if there is a trigger solution, that works without any bad side effects. If you find one, I would be all ears... Regards, Mathias



 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

I don't approve of modifying the install; seems like a CM nightmare to me.

Is there merit overriding the "read/share/edit" perms?:

string Override = 
"    Module readNoErrors(string NameMod, bools whatevers)
        {  noErrors() 
           Module mod = read(NameMod, whatevers)
           lastError()
           return(mod)
        }
        Module read(string NameMod, bools whatevers)
        {  readNoErrors(NameMod, whatevers)
        }
"   // end 'string Override'
evalTop_(Override)


put that as a "-cli " command line switch?

Sure would be nice to figure out how the user is requesting to open the module in a pre-open trigger. Is it remotely possible to look at the "stack" as see which exact perms preceed the trigger? i.e. look for "read()"?

-Louie

Re: Suppress #Include errors
Mathias Mamsch - Fri Aug 24 16:02:14 EDT 2012

llandale - Fri Aug 24 09:14:30 EDT 2012

I don't approve of modifying the install; seems like a CM nightmare to me.

Is there merit overriding the "read/share/edit" perms?:

string Override = 
"    Module readNoErrors(string NameMod, bools whatevers)
        {  noErrors() 
           Module mod = read(NameMod, whatevers)
           lastError()
           return(mod)
        }
        Module read(string NameMod, bools whatevers)
        {  readNoErrors(NameMod, whatevers)
        }
"   // end 'string Override'
evalTop_(Override)


put that as a "-cli " command line switch?

Sure would be nice to figure out how the user is requesting to open the module in a pre-open trigger. Is it remotely possible to look at the "stack" as see which exact perms preceed the trigger? i.e. look for "read()"?

-Louie

Hmm ... I think the problem is the same complexity as updating a DOORS client in a company, which also cannot be a CM nightmare. But nevertheless a solution that does not modify the install will modify DXL behaviour. Yes we could hook the perms at startup:
 

// Yes the DOORS client uses read/share/edit(string) to open a module
doors.exe -cli "evalTop_(\"Module read(string s) { print 123 }; Module share(string s) { print 456 }; Module edit(string s) { print 234;}\")"

 


successfully prevents opening a module from the module editor (of course one could apply a hook code here that uses noError / lastError). I guess the interference with other DXL scripts would be minimal (who uses the one string parameter perms for opening a module from a DXL script anyway). Still I have an itchy feeling hooking functions on top level. Not much experience with that. Might work. Why don't you deploy and then come back if any negative experiences come up? ;-)

Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Suppress #Include errors
Mathias Mamsch - Fri Aug 24 16:06:14 EDT 2012

llandale - Fri Aug 24 09:14:30 EDT 2012

I don't approve of modifying the install; seems like a CM nightmare to me.

Is there merit overriding the "read/share/edit" perms?:

string Override = 
"    Module readNoErrors(string NameMod, bools whatevers)
        {  noErrors() 
           Module mod = read(NameMod, whatevers)
           lastError()
           return(mod)
        }
        Module read(string NameMod, bools whatevers)
        {  readNoErrors(NameMod, whatevers)
        }
"   // end 'string Override'
evalTop_(Override)


put that as a "-cli " command line switch?

Sure would be nice to figure out how the user is requesting to open the module in a pre-open trigger. Is it remotely possible to look at the "stack" as see which exact perms preceed the trigger? i.e. look for "read()"?

-Louie

I do not know how deep you would need to dig, to find out the edit mode in a pre-open trigger. The DXL stack will be no help, since the triggers will be executed in their own context (each of which has its own stack). With enough time, one would probably find a way to do so, but I think this would result in a very bad hack, that you would want to avoid, as long as you have DXL only alternatives. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Suppress #Include errors
llandale - Sun Aug 26 14:46:00 EDT 2012

Mathias Mamsch - Fri Aug 24 16:02:14 EDT 2012

Hmm ... I think the problem is the same complexity as updating a DOORS client in a company, which also cannot be a CM nightmare. But nevertheless a solution that does not modify the install will modify DXL behaviour. Yes we could hook the perms at startup:
 

// Yes the DOORS client uses read/share/edit(string) to open a module
doors.exe -cli "evalTop_(\"Module read(string s) { print 123 }; Module share(string s) { print 456 }; Module edit(string s) { print 234;}\")"

 


successfully prevents opening a module from the module editor (of course one could apply a hook code here that uses noError / lastError). I guess the interference with other DXL scripts would be minimal (who uses the one string parameter perms for opening a module from a DXL script anyway). Still I have an itchy feeling hooking functions on top level. Not much experience with that. Might work. Why don't you deploy and then come back if any negative experiences come up? ;-)

Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

I can safely say I never thought I'd see the day that our diverse universes would touch and you would say these things:
  • "itchy feeling" doing something clever
  • "bad hack" doing something clever.
Both in one day no less. To me, EVERYTHING you do gives me an "itchy feeling" and is a "bad hack". Armegeddon must be coming; perhaps Isaac.

I think I'd be conserned with native DXL using these exact perms. May give it a whirl, but have decided to fix my immediate problem with a straight forward "itchy bad hack"; commenting out the offensive DXL code.
-Louie

Isaac: The Hurricane in the Gulf coming my way.